Skip to content

Changelog fix2#161

Merged
utkarsh232005 merged 23 commits into
KDM-cli:mainfrom
Yuvraj-Sarathe:changelog-fix2
Jun 13, 2026
Merged

Changelog fix2#161
utkarsh232005 merged 23 commits into
KDM-cli:mainfrom
Yuvraj-Sarathe:changelog-fix2

Conversation

@Yuvraj-Sarathe

@Yuvraj-Sarathe Yuvraj-Sarathe commented Jun 12, 2026

Copy link
Copy Markdown
Member

Fixes #149

image Screenshot 2026-06-12 193711

Summary by CodeRabbit

  • New Features

    • Introduced deploy v2 command for deployment
    • Added health check endpoint for system monitoring
  • Documentation

    • Updated README with release notes and commit history
    • Added upgrade guide for v2
    • Published detailed release notes for versions v2.0.0 and v2.0.1

Three fixes for the auto-changelog workflow:

1. Add explicit fromTag lookup — previously the action auto-detected the
previous tag, which failed for some version ranges (v2.0.0, v2.0.1),
producing completely empty doc files.

2. Fix label_extractor regex — added case-insensitive flag (?i) and
expanded alternatives (feature, docs?). PR titles like 'Feat:' or
'Fix/' were falling through to Uncategorized or producing empty
results.

3. Add git log fallback — if the action returns empty/'No changes',
generate a commit-based changelog instead. This guarantees no doc
file is ever blank.

Also regenerated the two empty docs (v2.0.0.md, v2.0.1.md) with proper
commit-level changelogs.
The secrets.GH_PAT was never configured in the repository's
Secrets settings. When undefined, GitHub Actions evaluates it as
an empty string, which overrides the default ${{ github.token }}
auto-generated GITHUB_TOKEN.

Both workflows already have permissions: contents: write which
gives the GITHUB_TOKEN sufficient scope for checkout and push.
Removing the explicit token parameter lets the default take effect.
…ut, add v2.0.3 doc

- Exclude docs/what-is-kdm.md from Version History listing
  (it's a conceptual overview, not a versioned release doc)
- Remove duplicate git checkout  line
- Generate missing docs/v2.0.3.md using git log fallback
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (2)
Validation error: Invalid input: expected string, received undefined at "reviews.path_instructions[3].path"; Invalid input: expected string, received undefined at "reviews.path_instructions[3].instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 66cf0ee9-0fe8-4b3a-a56d-f7123a55779d

📥 Commits

Reviewing files that changed from the base of the PR and between 3af89a0 and 15e11c2.

📒 Files selected for processing (1)
  • .github/scripts/verify-labeler.cjs

📝 Walkthrough

Walkthrough

This PR fixes empty changelog generation by computing Git tag ranges and implementing git-log fallback; adds a verification script for PR labeler detection logic; documents v2.0.0 and v2.0.1 releases; introduces health check and deploy v2 command; removes custom token from publish workflow.

Changes

PR Labeler Verification Script

Layer / File(s) Summary
Verification harness, config loading, and mock scaffolding
.github/scripts/verify-labeler.cjs
Script initialization loads automation config and prLabels, defines assert() helper for test reporting, and creates mock GitHub context and issues.addLabels tracking.
Label detection pure functions
.github/scripts/verify-labeler.cjs
Local implementations of detectType(), determineSize(), matchGlobPattern() with backslash normalization, detectModules() with deduplication, and complexity scoring/categorization functions.
Unit tests for detection functions
.github/scripts/verify-labeler.cjs
Targeted assertions validating type patterns, size thresholds, glob syntax, module extraction/deduplication, and complexity scoring across configured boundaries.
End-to-end scenario testing
.github/scripts/verify-labeler.cjs
E2E test stub and simulateLabels() function that validates four release scenarios (bug-fix, multi-module feature, refactor with complexity, undetectable type) and reports pass/fail summary.

Release Automation and Documentation

Layer / File(s) Summary
Changelog workflow version range computation
.github/workflows/changelog.yml
Adds "Determine version range" step computing fromTag/toTag from requested version; wires outputs into release-changelog-builder-action; updates regex to be case-insensitive and match docs-related keywords.
Changelog generation with git-log fallback and workflow updates
.github/workflows/changelog.yml
Derives VERSION from computed toTag, validates changelog output, and falls back to git-log-based "Commits" section when empty; updates README version-history filtering and commit message; changes fast-forward retry to 3-iteration exponential backoff.
Release notes and documentation updates
docs/README.md, docs/UPGRADE-v2.md, docs/v2.0.0.md, docs/v2.0.1.md
Adds "Commits" sections to v2.0.0.md and v2.0.1.md with detailed changelog entries; updates docs/README.md with v2.0.1 commits and removes what-is-kdm link; adds upgrade guide to UPGRADE-v2.md.
Deploy v2 command and health check endpoint
src/commands/deploy-v2.ts, src/monitor/health.ts
Introduces deploy-v2.ts with console output for deploy v2 command; introduces health.ts with exported check() function returning 'ok' status.
Publish workflow token cleanup
.github/workflows/publish.yml
Removes custom GH_PAT token from actions/checkout@v6, retaining fetch-depth: 0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • KDM-cli/kdm-cli#148: The new .github/scripts/verify-labeler.cjs directly duplicates and validates the PR labeler's detection logic (detectType, determineSize, module globbing, complexity bucketing) from the labeler introduced in that PR.
  • KDM-cli/kdm-cli#115: Both PRs modify .github/workflows/changelog.yml's release label/category mapping and commit-type regex for the changelog builder, so this PR's labeling changes coordinate with that PR's configuration overhaul.
  • KDM-cli/kdm-cli#77: The changelog workflow updates (tag-range computation, README version-history aggregation, fast-forward retry loop) overlap with that PR's edits to the same workflow.

Suggested labels

documentation, ci/cd, version2

Suggested reviewers

  • utkarsh232005
  • codescene-delta-analysis

Poem

🐰 A script to verify what labels we assign,
Release notes now flow when changelogs align,
Health checks and deploy commands take their place,
Git history speaks when empty files we face! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes out-of-scope changes: new deploy-v2 command, health check endpoint, and documentation additions (UPGRADE-v2.md, v2.0.0.md, v2.0.1.md) that go beyond fixing the changelog automation bug. Remove non-essential changes (deploy-v2.ts, health.ts, upgrade docs) unrelated to fixing issue #149, or document why they are necessary for the changelog fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Changelog fix2' is vague and generic, using non-descriptive language that doesn't convey meaningful information about what was actually fixed or changed. Revise the title to be more specific, e.g., 'Fix changelog generation to prevent empty files' or 'Repair versioned docs automation with git-log fallback'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR addresses issue #149 by fixing the changelog automation with multiple improvements: proper tag range detection, git-log fallback for empty changelogs, token configuration fix, and release labeling updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/UPGRADE-v2.md (1)

1-3: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify or complete the upgrade guide content.

The upgrade guide directs readers to "the new deploy command" but provides no link, command name, or usage instructions. The referenced deploy-v2 command in src/commands/deploy-v2.ts currently only logs 'deploy v2' and lacks actual implementation.

If the deploy command is incomplete or not yet released, either:

  1. Remove this file and re-add it when the feature is ready, or
  2. Expand the guidance with actual instructions (usage, examples, prerequisites).

Currently, users following this guide would encounter a placeholder implementation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/UPGRADE-v2.md` around lines 1 - 3, The upgrade guide is incomplete and
points to a placeholder command; either remove docs/UPGRADE-v2.md until the
feature is ready or expand it with real usage and examples for the deploy
command and implement the command behavior in src/commands/deploy-v2.ts (which
currently only logs 'deploy v2'). If you choose to expand the doc, add the exact
command name, required flags/arguments, prerequisites, and example invocations;
if you choose to postpone, delete the UPGRADE-v2.md file and add a TODO comment
in src/commands/deploy-v2.ts referencing the missing implementation so the
placeholder 'deploy v2' log is not mistaken for a finished feature.
🧹 Nitpick comments (6)
.github/scripts/verify-labeler.cjs (5)

27-66: ⚡ Quick win

Remove unused createMockContext() function.

This function is defined but never called. The E2E testing approach appears to have been abandoned in favor of the manual label simulation starting at line 271.

🧹 Proposed cleanup
-function createMockContext(title, files, additions = 50, deletions = 30) {
-  const labelsAdded = [];
-
-  const mockGithub = {
-    rest: {
-      pulls: {
-        get: async () => ({
-          data: { additions, deletions, changed_files: files.length },
-        }),
-        listFiles: async () => ({
-          data: files.map(f => ({ filename: f })),
-        }),
-      },
-    },
-  };
-
-  const mockContext = {
-    payload: {
-      pull_request: { title },
-    },
-  };
-
-  // Intercept addLabels to track what would be added
-  const originalLabelPR = labelPR;
-  // We patch by wrapping the bot context build
-  const patchedGithub = {
-    ...mockGithub,
-    rest: {
-      ...mockGithub.rest,
-      issues: {
-        addLabels: async (params) => {
-          labelsAdded.push(...params.labels);
-          return { data: {} };
-        },
-      },
-    },
-  };
-
-  return { github: patchedGithub, context: mockContext, labelsAdded };
-}
-
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/verify-labeler.cjs around lines 27 - 66, Remove the unused
testing helper createMockContext (and its inner bindings labelsAdded,
mockGithub, mockContext, originalLabelPR, patchedGithub) from
.github/scripts/verify-labeler.cjs; locate the function declaration named
createMockContext and delete it and any dangling references, then run lint/tests
to ensure no remaining references to createMockContext or its variables remain.

227-266: ⚡ Quick win

Remove unused runE2ETest() function.

This async function is defined but never called. The E2E testing section (lines 224-225) prints a header but doesn't execute any tests. Remove this dead code or implement the E2E test suite.

🧹 Proposed cleanup
-// ── End-to-end: simulate labelPR with a mock payload ──
-console.log('\n── E2E: labelPR (full flow) ──');
-
-async function runE2ETest(name, title, files, additions, deletions) {
-  const labelsAdded = [];
-  const totalChanges = additions + deletions;
-
-  const github = {
-    rest: {
-      pulls: {
-        get: async () => ({ data: { additions, deletions, changed_files: files.length } }),
-        listFiles: async () => ({ data: files.map(f => ({ filename: f })) }),
-      },
-      issues: {
-        addLabels: async (params) => { labelsAdded.push(...params.labels); return { data: {} }; },
-      },
-    },
-  };
-  const context = {
-    payload: { pull_request: { title, number: 42 } },
-    repo: { owner: 'test', repo: 'test' },
-  };
-
-  // Manually inline the addLabels to capture labels
-  // The real labelPR uses buildBotContext({github, context}) which returns {owner,repo,number,github,...}
-  // So we provide the right shape
-  const botContext = { github, owner: 'test', repo: 'test', number: 42, _labels: labelsAdded };
-  github.rest.issues.addLabels = async (params) => { labelsAdded.push(...params.labels); return { data: {} }; };
-
-  // Override buildBotContext to inject our _labels tracker
-  const capturedLabels = [];
-  const buildBotContextOrig = require('./helpers/api.cjs').buildBotContext;
-  // Instead, just run labelPR with a wrapped github
-  try {
-    await labelPR({ github, context });
-  } catch (e) {
-    // The labelPR function uses buildBotContext({github, context}) and expects specific shape
-    // If the mock isn't perfect, we still get console output
-    console.log(`    ${name}: ${e.message}`);
-    console.log(`    (E2E mocking requires exact API shape — see pure function tests above for coverage)`);
-    return;
-  }
-}
-
-// Fall back to pure function verification + manual label assembly test
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/verify-labeler.cjs around lines 227 - 266, The async helper
runE2ETest is dead code (defined but never invoked); remove the entire
runE2ETest function declaration from the script to eliminate the unused
function, or if E2E coverage is intended, replace the removal by invoking
runE2ETest appropriately from the E2E section and ensure the mocked
github/context shape matches what labelPR and buildBotContext expect
(references: runE2ETest, labelPR, buildBotContext).

72-86: ⚡ Quick win

Remove unused vm.Script setup.

The vm.Script approach to extract internal functions from pr-labeler.cjs is set up but never executed. The script later duplicates the functions directly (lines 90-146) instead.

🧹 Proposed cleanup
-const fs = require('fs');
-const vm = require('vm');
-
-const source = fs.readFileSync(require.resolve('./pr-labeler.cjs'), 'utf8');
-// Wrap in an IIFE that returns the internal functions via module scope
-const script = new vm.Script(`
-  const module = { exports: {} };
-  const require = (m) => {
-    if (m === './helpers/api.cjs') return { buildBotContext: (x) => x, addLabels: async (ctx, labels) => { ctx._labels.push(...labels); return {success:true}; } };
-    if (m === './helpers/config-loader.cjs') return { loadAutomationConfig: () => (${JSON.stringify(config)}) };
-    return {};
-  };
-  ${source}
-  module.exports;
-`);
-
-// We need to eval in a sandbox. Simpler: just duplicate the pure functions here.
-
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/verify-labeler.cjs around lines 72 - 86, The vm.Script setup
(variables source, script, and the vm.Script wrapper that defines
module/require) is unused and duplicates functionality later; remove the unused
vm.Script-related code (the const source = fs.readFileSync(...), the const
script = new vm.Script(`...`) block and any unused vm/require stubs) so only the
direct function duplicates remain, and ensure any required mocks referenced
later (e.g., the inline require replacement for './helpers/api.cjs' and
'./helpers/config-loader.cjs') are preserved where actually used; target the
vm.Script, source, script and unused require shim declarations in
.github/scripts/verify-labeler.cjs to clean up the dead setup.

171-181: ⚡ Quick win

Size threshold tests are tightly coupled to config values.

The assertions hardcode specific boundaries (10, 50, 200, 500) that assume exact config values for prLabels.size. If the config changes, these tests will break even though the logic may be correct. Consider reading actual thresholds from the loaded config to make tests more robust.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/verify-labeler.cjs around lines 171 - 181, The tests
hardcode size boundaries causing brittleness; update the assertions for
determineSize and prLabels.size to derive threshold values from the same config
used by the labeler instead of literal numbers — load the config (the
module/variable that provides size thresholds), extract the boundary values
(e.g., smallThreshold, mediumThreshold, largeThreshold, xlargeThreshold or an
array of thresholds) and use those values in the assert calls so determineSize(
threshold-1, prLabels.size ) and determineSize( threshold, prLabels.size ) tests
reflect the configured boundaries dynamically.

197-201: ⚡ Quick win

Module detection test assumes exact count.

The assertion mods1.length === 2 is brittle because it depends on the exact modulePaths configuration. If the config adds overlapping patterns (e.g., src/**/*.ts mapping to a new module), this test will fail even though the detection logic is correct.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/verify-labeler.cjs around lines 197 - 201, Test is brittle
because it asserts exact module count; update the checks around
files1/mods1/detectModules so we only verify the expected modules are present
rather than enforcing mods1.length === 2. Concretely, remove or replace the
assert('No spurious modules', mods1.length === 2) with an assertion that the
expected modules are included (e.g., ensure mods1.includes('cli') and
mods1.includes('config') or check an expectedModules array and assert every
expectedModules.every(m => mods1.includes(m))). This keeps the test focused on
presence of 'cli' and 'config' without failing when modulePaths adds overlapping
patterns.
docs/README.md (1)

6-6: ⚡ Quick win

Fix markdown heading levels in release documentation files.

Three documentation files contain the same markdown heading hierarchy violation: the "Commits" section (h3) immediately follows the main heading (h1) without an intermediate h2 level. Per CommonMark specification, heading levels should increment by one level at a time.

Affected files:

  • docs/README.md line 6: ### Commits should be ## Commits
  • docs/v2.0.0.md line 4: ### Commits should be ## Commits
  • docs/v2.0.1.md line 4: ### Commits should be ## Commits
Fix for all three files

Change ### Commits to ## Commits in each file.

-### Commits
+## Commits
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/README.md` at line 6, Replace the incorrect third-level heading "###
Commits" with a second-level heading "## Commits" in each affected release
documentation file so the heading hierarchy increments correctly from the main
H1; search for the exact string "### Commits" and change it to "## Commits" in
the files containing release notes (e.g., where the main title is followed
immediately by the "Commits" section).

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/verify-labeler.cjs:
- Line 342: The console output for scenario 3 uses the wrong variable — change
the console.log that currently references labels2 to reference labels3 so it
prints the refactor PR labels; locate the log statement that reads `Labels:
${labels2.join(', ')}` (near the scenario 3/refactor PR handling) and replace
the variable with `labels3`.
- Around line 90-146: The six helper functions (detectType, determineSize,
matchGlobPattern, detectModules, calculateComplexity, determineComplexity) are
duplicated here; remove these copies and import them from the canonical
implementation by refactoring pr-labeler.cjs to export the helpers alongside
labelPR (e.g., export detectType, determineSize, matchGlobPattern,
detectModules, calculateComplexity, determineComplexity) and then replace the
local definitions in verify-labeler.cjs with imports that use those exported
symbols so the verifier uses the single source of truth.

In @.github/workflows/changelog.yml:
- Around line 37-50: Validate that the supplied VERSION is an existing tag
before using it (use git show-ref or git rev-parse on refs/tags/"$VERSION" and
fail/exit with a clear message if not) and then compute fromTag/toTag by
selecting tags with semver-aware or release-only ordering instead of git tag
--sort=-version:refname; specifically, keep the existing variables VERSION,
toTag and fromTag but replace the git tag listing step with one that filters out
prerelease tags (e.g., match a strict semver release regex like
^v?MAJOR.MINOR.PATCH) or use --sort=-creatordate plus a post-filter to skip
prereleases so the loop that sets fromTag does not pick prerelease tags (ensure
the workflow exits or falls back safely if no previous release tag is found).
- Line 40: Move the inlined VERSION expression out of the shell body and into
the job env (set VERSION_RAW="${{ github.event.inputs.version || github.ref_name
}}"), then in the version_range step (id: version_range) assign VERSION from
VERSION_RAW and perform strict validation (regex for semantic version like
^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9]+)?$) before writing to GITHUB_OUTPUT (toTag)
or using VERSION in git args/paths; fail the step early with a clear error if
validation fails to prevent command-substitution injection via VERSION.

In `@README.md`:
- Line 12: The word "trial" is incorrectly placed inline with the opening tag of
<div align="center">; remove that stray text and relocate it into the banner
content—either append "(trial)" to the main heading (the "# KDM — Kubernetes +
Docker Monitoring CLI" heading), or insert a separate label (e.g., a
<small>trial</small> or bold "[trial]") as a child element immediately before
the heading inside the same <div align="center"> so the banner renders
correctly.

In `@src/commands/deploy-v2.ts`:
- Around line 1-2: The new file deploy-v2.ts only logs and is not wired into the
CLI; either implement and export a proper registration function (e.g., export
function registerDeployV2Command(program) that sets up options/handler instead
of console.log) and then import and call that registration from
src/commands/root.ts where other commands are registered, or delete the file
until ready; make sure the exported symbol name you choose (e.g.,
registerDeployV2Command) matches the import in root.ts so the command is
actually included in the CLI.

---

Outside diff comments:
In `@docs/UPGRADE-v2.md`:
- Around line 1-3: The upgrade guide is incomplete and points to a placeholder
command; either remove docs/UPGRADE-v2.md until the feature is ready or expand
it with real usage and examples for the deploy command and implement the command
behavior in src/commands/deploy-v2.ts (which currently only logs 'deploy v2').
If you choose to expand the doc, add the exact command name, required
flags/arguments, prerequisites, and example invocations; if you choose to
postpone, delete the UPGRADE-v2.md file and add a TODO comment in
src/commands/deploy-v2.ts referencing the missing implementation so the
placeholder 'deploy v2' log is not mistaken for a finished feature.

---

Nitpick comments:
In @.github/scripts/verify-labeler.cjs:
- Around line 27-66: Remove the unused testing helper createMockContext (and its
inner bindings labelsAdded, mockGithub, mockContext, originalLabelPR,
patchedGithub) from .github/scripts/verify-labeler.cjs; locate the function
declaration named createMockContext and delete it and any dangling references,
then run lint/tests to ensure no remaining references to createMockContext or
its variables remain.
- Around line 227-266: The async helper runE2ETest is dead code (defined but
never invoked); remove the entire runE2ETest function declaration from the
script to eliminate the unused function, or if E2E coverage is intended, replace
the removal by invoking runE2ETest appropriately from the E2E section and ensure
the mocked github/context shape matches what labelPR and buildBotContext expect
(references: runE2ETest, labelPR, buildBotContext).
- Around line 72-86: The vm.Script setup (variables source, script, and the
vm.Script wrapper that defines module/require) is unused and duplicates
functionality later; remove the unused vm.Script-related code (the const source
= fs.readFileSync(...), the const script = new vm.Script(`...`) block and any
unused vm/require stubs) so only the direct function duplicates remain, and
ensure any required mocks referenced later (e.g., the inline require replacement
for './helpers/api.cjs' and './helpers/config-loader.cjs') are preserved where
actually used; target the vm.Script, source, script and unused require shim
declarations in .github/scripts/verify-labeler.cjs to clean up the dead setup.
- Around line 171-181: The tests hardcode size boundaries causing brittleness;
update the assertions for determineSize and prLabels.size to derive threshold
values from the same config used by the labeler instead of literal numbers —
load the config (the module/variable that provides size thresholds), extract the
boundary values (e.g., smallThreshold, mediumThreshold, largeThreshold,
xlargeThreshold or an array of thresholds) and use those values in the assert
calls so determineSize( threshold-1, prLabels.size ) and determineSize(
threshold, prLabels.size ) tests reflect the configured boundaries dynamically.
- Around line 197-201: Test is brittle because it asserts exact module count;
update the checks around files1/mods1/detectModules so we only verify the
expected modules are present rather than enforcing mods1.length === 2.
Concretely, remove or replace the assert('No spurious modules', mods1.length ===
2) with an assertion that the expected modules are included (e.g., ensure
mods1.includes('cli') and mods1.includes('config') or check an expectedModules
array and assert every expectedModules.every(m => mods1.includes(m))). This
keeps the test focused on presence of 'cli' and 'config' without failing when
modulePaths adds overlapping patterns.

In `@docs/README.md`:
- Line 6: Replace the incorrect third-level heading "### Commits" with a
second-level heading "## Commits" in each affected release documentation file so
the heading hierarchy increments correctly from the main H1; search for the
exact string "### Commits" and change it to "## Commits" in the files containing
release notes (e.g., where the main title is followed immediately by the
"Commits" section).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a69e2189-3499-448b-956f-9ed2c4544056

📥 Commits

Reviewing files that changed from the base of the PR and between 196eaba and 3af89a0.

📒 Files selected for processing (10)
  • .github/scripts/verify-labeler.cjs
  • .github/workflows/changelog.yml
  • .github/workflows/publish.yml
  • README.md
  • docs/README.md
  • docs/UPGRADE-v2.md
  • docs/v2.0.0.md
  • docs/v2.0.1.md
  • src/commands/deploy-v2.ts
  • src/monitor/health.ts
💤 Files with no reviewable changes (1)
  • .github/workflows/publish.yml

Comment on lines +90 to +146
function detectType(title) {
if (!title || typeof title !== 'string') return null;
const upper = title.toUpperCase();
const kdm = upper.match(/\[KDM-\d+-(FIX|FEAT|REFACTOR)/);
if (kdm) { const map = { FIX: 'bugFix', FEAT: 'feature', REFACTOR: 'refactor' }; return map[kdm[1]] || null; }
const cc = title.match(/^(fix|feat|refactor)(\(|:)/i);
if (cc) { const map = { fix: 'bugFix', feat: 'feature', refactor: 'refactor' }; return map[cc[1].toLowerCase()] || null; }
const plain = title.match(/^(fix|feature|refactor)\b/i);
if (plain) { const map = { fix: 'bugFix', feature: 'feature', refactor: 'refactor' }; return map[plain[1].toLowerCase()] || null; }
return null;
}

function determineSize(totalChanges, sizeConfig) {
for (const key of ['xs', 's', 'm', 'l', 'xl']) {
const max = sizeConfig[key]?.maxChanges;
if (max === null) return key;
if (totalChanges <= max) return key;
}
return 'xl';
}

function matchGlobPattern(filepath, pattern) {
const normPath = filepath.replace(/\\/g, '/');
const normPat = pattern.replace(/\\/g, '/');
let re = '';
for (let i = 0; i < normPat.length; i++) {
const ch = normPat[i];
if (ch === '*' && normPat[i + 1] === '*') { re += '.*'; i += normPat[i + 2] === '/' ? 2 : 1; }
else if (ch === '*') { re += '[^/]*'; }
else if (ch === '?') { re += '[^/]'; }
else { re += ch.replace(/[.+^${}()|[\]\\]/g, '\\$&'); }
}
return new RegExp('^' + re + '$').test(normPath);
}

function detectModules(files, modulePaths) {
const matched = new Set();
for (const file of files) {
for (const [pattern, mod] of Object.entries(modulePaths)) {
if (matchGlobPattern(file.filename, pattern)) matched.add(mod);
}
}
return Array.from(matched);
}

function calculateComplexity(fileCount, totalChanges, moduleCount) {
return Math.round(fileCount * 2 + totalChanges / 50 + moduleCount * 5);
}

function determineComplexity(score, complexityConfig) {
for (const key of ['easy', 'medium', 'complex']) {
const max = complexityConfig[key]?.maxScore;
if (max === null) return key;
if (score <= max) return key;
}
return 'complex';
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

Critical code duplication: functions copied from pr-labeler.cjs.

Lines 90-146 duplicate six pure functions (detectType, determineSize, matchGlobPattern, detectModules, calculateComplexity, determineComplexity) from pr-labeler.cjs. This creates a critical maintenance hazard: if the real implementation changes, these tests will continue passing while validating outdated logic, making the verification suite unreliable.

Recommended solution: Refactor pr-labeler.cjs to export both labelPR and the helper functions, then import them here:

// In pr-labeler.cjs, at the end:
+module.exports = labelPR;
+module.exports.detectType = detectType;
+module.exports.determineSize = determineSize;
+module.exports.matchGlobPattern = matchGlobPattern;
+module.exports.detectModules = detectModules;
+module.exports.calculateComplexity = calculateComplexity;
+module.exports.determineComplexity = determineComplexity;

// In verify-labeler.cjs:
-function detectType(title) { ... }
-function determineSize(totalChanges, sizeConfig) { ... }
-function matchGlobPattern(filepath, pattern) { ... }
-function detectModules(files, modulePaths) { ... }
-function calculateComplexity(fileCount, totalChanges, moduleCount) { ... }
-function determineComplexity(score, complexityConfig) { ... }
+const {
+  detectType,
+  determineSize,
+  matchGlobPattern,
+  detectModules,
+  calculateComplexity,
+  determineComplexity
+} = labelPR;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/verify-labeler.cjs around lines 90 - 146, The six helper
functions (detectType, determineSize, matchGlobPattern, detectModules,
calculateComplexity, determineComplexity) are duplicated here; remove these
copies and import them from the canonical implementation by refactoring
pr-labeler.cjs to export the helpers alongside labelPR (e.g., export detectType,
determineSize, matchGlobPattern, detectModules, calculateComplexity,
determineComplexity) and then replace the local definitions in
verify-labeler.cjs with imports that use those exported symbols so the verifier
uses the single source of truth.

Comment thread .github/scripts/verify-labeler.cjs Outdated
Comment thread .github/workflows/changelog.yml
Comment thread .github/workflows/changelog.yml
Comment thread README.md Outdated
Comment thread src/commands/deploy-v2.ts Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Comment thread docs/UPGRADE-v2.md
Comment thread README.md
Comment thread README.md Outdated
Comment thread README.md Outdated
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is required to bypass the rules of the branch

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? because as far as I can remember, almost every CI/CD github action requires this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats what i am saying you have removed it pls add or revoke the changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please dont change the publish.yml

codescene-delta-analysis[bot]

This comment was marked as outdated.

- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please dont change the publish.yml

Comment thread docs/UPGRADE-v2.md
@Yuvraj-Sarathe

Copy link
Copy Markdown
Member Author

@utkarsh232005 done, and also a request: I would like to not work on anything for the next few weeks, maybe a month.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Comment thread src/monitor/health.ts Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the point of this line ?

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No application code in the PR — skipped Code Health checks.

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@utkarsh232005 utkarsh232005 merged commit a7672d2 into KDM-cli:main Jun 13, 2026
20 checks passed
@Yuvraj-Sarathe Yuvraj-Sarathe deleted the changelog-fix2 branch June 13, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Auto Changelog & Versioned Docs is writing empty file when triggred

2 participants